import QueueP.LoopQueue;
import QueueP.Queue;

import java.util.Random;

public class QueueTest {
// 测试使用q运行opCount个enqueueu和dequeue操作所需要的时间，单位：秒
    private static  double testQueue(Queue<Integer> q, int opCount){

        long startTime = System.nanoTime();

        Random random = new Random();

        for (int i=0;i<opCount;i++){
            q.enqueue(random.nextInt(Integer.MAX_VALUE));
        }
        for (int i=0;i<opCount;i++){
            q.dequeue();
        }
        long endTime = System.nanoTime();
        return (endTime - startTime) / 1000000000.0;

    }

    public static void main(String[] args) {
        int opCount=100000;

       /* QueueP.ArrayQueue<Integer> arrayQueue = new QueueP.ArrayQueue<>();
        double time1 = testQueue(arrayQueue, opCount);
        System.out.println("ArrayQue,time:"+time1+"s");*/

        LoopQueue<Integer> loopQueue = new LoopQueue<>();
        double time2 = testQueue(loopQueue, opCount);

        System.out.println("QueueP.LoopQueue ,time:"+time2+"s");
    }



}
